
clear 


lambda_i = 'phi';
fVec = linspace(0,2048,2048);
Params.totalMass = 20;
Params.eta = 0.25;
Params.dL = 1;
Params.dEff = 1;
Params.startTime = 0;
Params.startPhase = 0;

Params.theta = 0.810795263059348;
Params.phi = -2.08405676907401;
Params.psi   = 0;
Params.iota  = 0;
Params.Det = LoadDetectorData('LHO');
[Sh] = detnoisepsd('AdvLIGO',fVec);

[dAeffBydLamba] = AeffDerivative(lambda_i, fVec, Params);
[dPsieffBydLamba] = PsieffDerivative(lambda_i, fVec, Params);

col = 'r';

figure(1)
semilogx(fVec,dAeffBydLamba,col)
grid on
hold on
xlabel('f')
ylabel(sprintf('d A_{eff}/ d %s',lambda_i))

figure(2)
semilogx(fVec,dPsieffBydLamba,col)
grid on
hold on
xlabel('f')
ylabel(sprintf('d \\Psi_{eff}/ d %s',lambda_i))

% compute the fisher matrix elements
psiVec = linspace(0,pi,1000);
for iPsi=1:length(psiVec)
    Params.psi   = psiVec(iPsi);
    [dAeffBydLamba] = AeffDerivative(lambda_i, fVec, Params);
    dAOvlp(iPsi) = sqrt(sum(dAeffBydLamba(2:end).^2./Sh(2:end)));
end

mean(dAOvlp)/dAOvlp(1)


figure
plot(psiVec,dAOvlp,'c')
grid on
xlabel('\psi')
